package ee.example.final_work

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.example.final_work.R

class Content : AppCompatActivity() {
    private var imageView1: ImageView? = null
    private var textView1: TextView? = null
    private var textView2: TextView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_content)
        intidata()
        val intent = intent
        val place = intent.getStringExtra("id")
        val database = PlaceDatabase(this, PlaceDatabase.TABLE_NAME, null, 1)
        val list = database.findById(place!!)
        val data = list[0]
        textView1!!.text = data.title
        textView2!!.text = data.content
        imageView1!!.setImageResource(MyAdapter.getDrawableId(this, data.pic))
    }

    private fun intidata() {
        imageView1 = findViewById<View>(R.id.conImage1) as ImageView
        textView1 = findViewById(R.id.conText1)
        textView2 = findViewById(R.id.conText2)
    }
}